package com.mark.web.data.mapper;

import com.mark.web.data.entity.po.Shipping;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @Description: 收货地址dao接口，用于收货地址的数据库操作
 * @Author: Mark
 * @CreateDate: 2018/9/21
 * @Version: 2.0
 * @Copyright : 豆浆油条个人非正式工作室
 */
@Mapper
public interface ShippingMapper {

    int insert(Shipping record);

    int insertSelective(Shipping record);

    int deleteByPrimaryKey(Integer id);

    /**
     * 根据用户Id和地址Id删除收货地址
     * @param currentUserId：用户id
     * @param shippingId：收货地址id
     * @return ：影响的行数
     */
    int deleteShippingByUserIdAndShippingId(@Param("currentUserId") Integer currentUserId,
                                            @Param("shippingId") Integer shippingId);

    int updateByPrimaryKeySelective(Shipping record);

    int updateByPrimaryKey(Shipping record);

    int updateByShipping(Shipping shipping);

    Shipping selectByPrimaryKey(Integer id);

    /**
     *用户根据收货地址Id查看收货信息
     * @param currentUserId ：用户id
     * @param shippingId：收货地址id
     * @return ： 收货地址对象
     */
    Shipping selectByShippingIdAndUserId(@Param("currentUserId") Integer currentUserId,
                                         @Param("shippingId") Integer shippingId);

    /**
     * 根据用户id查找收货地址信息
     * @param currentUserId：用户id
     * @return ： 收货地址列表
     */
    List<Shipping> selectAllByUserId(Integer currentUserId);
}